home *** CD-ROM | disk | FTP | other *** search
/ Disc to the Future 2 / Disc to the Future Part II Programmer's Reference (Wayzata Technology)(6013)(1992).bin / MAC / THINKC / 4_0 / FLEX-TC_ / FLEXDEF.H < prev    next >
Text File  |  1990-01-03  |  22KB  |  621 lines

  1. /* flexdef - definitions file for flex */
  2.  
  3. /*
  4.  * Copyright (c) 1989 The Regents of the University of California.
  5.  * All rights reserved.
  6.  *
  7.  * This code is derived from software contributed to Berkeley by
  8.  * Vern Paxson.
  9.  * 
  10.  * The United States Government has rights in this work pursuant to
  11.  * contract no. DE-AC03-76SF00098 between the United States Department of
  12.  * Energy and the University of California.
  13.  *
  14.  * Redistribution and use in source and binary forms are permitted
  15.  * provided that the above copyright notice and this paragraph are
  16.  * duplicated in all such forms and that any documentation,
  17.  * advertising materials, and other materials related to such
  18.  * distribution and use acknowledge that the software was developed
  19.  * by the University of California, Berkeley.  The name of the
  20.  * University may not be used to endorse or promote products derived
  21.  * from this software without specific prior written permission.
  22.  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
  23.  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  24.  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  25.  */
  26.  
  27. /* @(#) $Header: flexdef.h,v 2.0 89/06/20 15:49:50 vern Locked $ (LBL) */
  28.  
  29. #ifndef FILE
  30. #include <stdio.h>
  31. #endif
  32.  
  33. #ifdef THINK_C
  34. #define SYS_V
  35. #endif
  36.  
  37. #ifdef SYS_V
  38. #include <string.h>
  39.  
  40. #ifdef AMIGA
  41. #define bzero(s, n) setmem((char *)(s), (unsigned)(n), '\0')
  42. #define abs(x) ((x) < 0 ? -(x) : (x))
  43. #else
  44. #define bzero(s, n) memset((char *)(s), '\0', (unsigned)(n))
  45. #endif
  46.  
  47. #ifndef VMS
  48. #ifndef THINK_C
  49. char *memset();
  50. #endif
  51. #else
  52. /* memset is needed for old versions of the VMS C runtime library */
  53. #define memset(s, c, n) \
  54.     { \
  55.     register char *t = s; \
  56.     register unsigned int m = n; \
  57.     while ( m-- > 0 ) \
  58.         *t++ = c; \
  59.     }
  60. #define unlink delete
  61. #define SHORT_FILE_NAMES
  62. #endif
  63. #endif
  64.  
  65. #ifdef THINK_C
  66. #define bcopy(s,d,l)    memcpy ((d), (s), (l))
  67. #endif
  68.  
  69. #ifndef SYS_V
  70. #include <strings.h>
  71. #ifdef lint
  72. char *sprintf(); /* keep lint happy */
  73. #endif /* lint */
  74. #endif /* not SYS_V */
  75.  
  76.  
  77. /* maximum line length we'll have to deal with */
  78. #define MAXLINE BUFSIZ
  79.  
  80. /* maximum size of file name */
  81. #define FILENAMESIZE 1024
  82.  
  83. #define min(x,y) ((x) < (y) ? (x) : (y))
  84. #define max(x,y) ((x) > (y) ? (x) : (y))
  85.  
  86. #ifdef MS_DOS
  87. #define abs(x) ((x) < 0 ? -(x) : (x))
  88. #define SHORT_FILE_NAMES
  89. #endif
  90.  
  91. #define true 1
  92. #define false 0
  93.  
  94.  
  95. #ifndef DEFAULT_SKELETON_FILE
  96. #define DEFAULT_SKELETON_FILE "flex.skel"
  97. #endif
  98.  
  99. /* special chk[] values marking the slots taking by end-of-buffer and action
  100.  * numbers
  101.  */
  102. #define EOB_POSITION -1
  103. #define ACTION_POSITION -2
  104.  
  105. /* number of data items per line for -f output */
  106. #define NUMDATAITEMS 10
  107.  
  108. /* number of lines of data in -f output before inserting a blank line for
  109.  * readability.
  110.  */
  111. #define NUMDATALINES 10
  112.  
  113. /* transition_struct_out() definitions */
  114. #define TRANS_STRUCT_PRINT_LENGTH 15
  115.  
  116. /* returns true if an nfa state has an epsilon out-transition slot
  117.  * that can be used.  This definition is currently not used.
  118.  */
  119. #define FREE_EPSILON(state) \
  120.     (transchar[state] == SYM_EPSILON && \
  121.      trans2[state] == NO_TRANSITION && \
  122.      finalst[state] != state)
  123.  
  124. /* returns true if an nfa state has an epsilon out-transition character
  125.  * and both slots are free
  126.  */
  127. #define SUPER_FREE_EPSILON(state) \
  128.     (transchar[state] == SYM_EPSILON && \
  129.      trans1[state] == NO_TRANSITION) \
  130.  
  131. /* maximum number of NFA states that can comprise a DFA state.  It's real
  132.  * big because if there's a lot of rules, the initial state will have a
  133.  * huge epsilon closure.
  134.  */
  135. #define INITIAL_MAX_DFA_SIZE 750
  136. #define MAX_DFA_SIZE_INCREMENT 750
  137.  
  138. /* array names to be used in generated machine.  They're short because
  139.  * we write out one data statement (which names the array) for each element
  140.  * in the array.
  141.  */
  142.  
  143. /* points to list of rules accepted for a state */
  144. #define ALIST "yy_accept"
  145. #define ACCEPT "yy_acclist"    /* list of rules accepted for a state */
  146. #define ECARRAY "yy_ec"    /* maps input characters to equivalence classes */
  147. /* maps equivalence classes to meta-equivalence classes */
  148. #define MATCHARRAY "yy_meta"
  149. #define BASEARRAY "yy_base"    /* "base" array */
  150. #define DEFARRAY "yy_def"    /* "default" array */
  151. #define NEXTARRAY "yy_nxt"    /* "next" array */
  152. #define CHECKARRAY "yy_chk"    /* "check" array */
  153.  
  154.  
  155. /* a note on the following masks.  They are used to mark accepting numbers
  156.  * as being special.  As such, they implicitly limit the number of accepting
  157.  * numbers (i.e., rules) because if there are too many rules the rule numbers
  158.  * will overload the mask bits.  Fortunately, this limit is \large/ (0x2000 ==
  159.  * 8192) so unlikely to actually cause any problems.  A check is made in
  160.  * new_rule() to ensure that this limit is not reached.
  161.  */
  162.  
  163. /* mask to mark a trailing context accepting number */
  164. #define YY_TRAILING_MASK 0x2000
  165.  
  166. /* mask to mark the accepting number of the "head" of a trailing context rule */
  167. #define YY_TRAILING_HEAD_MASK 0x4000
  168.  
  169. /* maximum number of rules, as outlined in the above note */
  170. #define MAX_RULE (YY_TRAILING_MASK - 1)
  171.  
  172.  
  173. /* NIL must be 0.  If not, its special meaning when making equivalence classes
  174.  * (it marks the representative of a given e.c.) will be unidentifiable
  175.  */
  176. #define NIL 0
  177.  
  178. #define JAM -1    /* to mark a missing DFA transition */
  179. #define NO_TRANSITION NIL
  180. #define UNIQUE -1    /* marks a symbol as an e.c. representative */
  181. #define INFINITY -1    /* for x{5,} constructions */
  182.  
  183. /* size of input alphabet - should be size of ASCII set */
  184. #define CSIZE 127
  185.  
  186. #define INITIAL_MAX_CCLS 100    /* max number of unique character classes */
  187. #define MAX_CCLS_INCREMENT 100
  188.  
  189. /* size of table holding members of character classes */
  190. #define INITIAL_MAX_CCL_TBL_SIZE 500
  191. #define MAX_CCL_TBL_SIZE_INCREMENT 250
  192.  
  193. #define INITIAL_MAX_RULES 100    /* default maximum number of rules */
  194. #define MAX_RULES_INCREMENT 100
  195.  
  196. #define INITIAL_MNS 2000    /* default maximum number of nfa states */
  197. #define MNS_INCREMENT 1000    /* amount to bump above by if it's not enough */
  198.  
  199. #define INITIAL_MAX_DFAS 1000    /* default maximum number of dfa states */
  200. #define MAX_DFAS_INCREMENT 1000
  201.  
  202. #define JAMSTATE -32766    /* marks a reference to the state that always jams */
  203.  
  204. /* enough so that if it's subtracted from an NFA state number, the result
  205.  * is guaranteed to be negative
  206.  */
  207. #define MARKER_DIFFERENCE 32000
  208. #define MAXIMUM_MNS 31999
  209.  
  210. /* maximum number of nxt/chk pairs for non-templates */
  211. #define INITIAL_MAX_XPAIRS 2000
  212. #define MAX_XPAIRS_INCREMENT 2000
  213.  
  214. /* maximum number of nxt/chk pairs needed for templates */
  215. #define INITIAL_MAX_TEMPLATE_XPAIRS 2500
  216. #define MAX_TEMPLATE_XPAIRS_INCREMENT 2500
  217.  
  218. #define SYM_EPSILON 0    /* to mark transitions on the symbol epsilon */
  219.  
  220. #define INITIAL_MAX_SCS 40    /* maximum number of start conditions */
  221. #define MAX_SCS_INCREMENT 40    /* amount to bump by if it's not enough */
  222.  
  223. #define ONE_STACK_SIZE 500    /* stack of states with only one out-transition */
  224. #define SAME_TRANS -1    /* transition is the same as "default" entry for state */
  225.  
  226. /* the following percentages are used to tune table compression:
  227.  
  228.  * the percentage the number of out-transitions a state must be of the
  229.  * number of equivalence classes in order to be considered for table
  230.  * compaction by using protos
  231.  */
  232. #define PROTO_SIZE_PERCENTAGE 15
  233.  
  234. /* the percentage the number of homogeneous out-transitions of a state
  235.  * must be of the number of total out-transitions of the state in order
  236.  * that the state's transition table is first compared with a potential 
  237.  * template of the most common out-transition instead of with the first
  238.  * proto in the proto queue
  239.  */
  240. #define CHECK_COM_PERCENTAGE 50
  241.  
  242. /* the percentage the number of differences between a state's transition
  243.  * table and the proto it was first compared with must be of the total
  244.  * number of out-transitions of the state in order to keep the first
  245.  * proto as a good match and not search any further
  246.  */
  247. #define FIRST_MATCH_DIFF_PERCENTAGE 10
  248.  
  249. /* the percentage the number of differences between a state's transition
  250.  * table and the most similar proto must be of the state's total number
  251.  * of out-transitions to use the proto as an acceptable close match
  252.  */
  253. #define ACCEPTABLE_DIFF_PERCENTAGE 50
  254.  
  255. /* the percentage the number of homogeneous out-transitions of a state
  256.  * must be of the number of total out-transitions of the state in order
  257.  * to consider making a template from the state
  258.  */
  259. #define TEMPLATE_SAME_PERCENTAGE 60
  260.  
  261. /* the percentage the number of differences between a state's transition
  262.  * table and the most similar proto must be of the state's total number
  263.  * of out-transitions to create a new proto from the state
  264.  */
  265. #define NEW_PROTO_DIFF_PERCENTAGE 20
  266.  
  267. /* the percentage the total number of out-transitions of a state must be
  268.  * of the number of equivalence classes in order to consider trying to
  269.  * fit the transition table into "holes" inside the nxt/chk table.
  270.  */
  271. #define INTERIOR_FIT_PERCENTAGE 15
  272.  
  273. /* size of region set aside to cache the complete transition table of
  274.  * protos on the proto queue to enable quick comparisons
  275.  */
  276. #define PROT_SAVE_SIZE 2000
  277.  
  278. #define MSP 50    /* maximum number of saved protos (protos on the proto queue) */
  279.  
  280. /* maximum number of out-transitions a state can have that we'll rummage
  281.  * around through the interior of the internal fast table looking for a
  282.  * spot for it
  283.  */
  284. #define MAX_XTIONS_FULL_INTERIOR_FIT 4
  285.  
  286. /* maximum number of rules which will be reported as being associated
  287.  * with a DFA state
  288.  */
  289. #define MAX_ASSOC_RULES 100
  290.  
  291. /* number that, if used to subscript an array, has a good chance of producing
  292.  * an error; should be small enough to fit into a short
  293.  */
  294. #define BAD_SUBSCRIPT -32767
  295.  
  296. /* absolute value of largest number that can be stored in a short, with a
  297.  * bit of slop thrown in for general paranoia.
  298.  */
  299. #define MAX_SHORT 32766
  300.  
  301.  
  302. /* Declarations for global variables. */
  303.  
  304. /* variables for symbol tables:
  305.  * sctbl - start-condition symbol table
  306.  * ndtbl - name-definition symbol table
  307.  * ccltab - character class text symbol table
  308.  */
  309.  
  310. struct hash_entry
  311.     {
  312.     struct hash_entry *prev, *next;
  313.     char *name;
  314.     char *str_val;
  315.     int int_val;
  316.     } ;
  317.  
  318. #ifdef THINK_C
  319. typedef struct hash_entry **hash_table;
  320. #else
  321. typedef struct hash_entry *hash_table[];
  322. #endif
  323.  
  324. #define NAME_TABLE_HASH_SIZE 101
  325. #define START_COND_HASH_SIZE 101
  326. #define CCL_HASH_SIZE 101
  327.  
  328. extern struct hash_entry *ndtbl[NAME_TABLE_HASH_SIZE]; 
  329. extern struct hash_entry *sctbl[START_COND_HASH_SIZE];
  330. extern struct hash_entry *ccltab[CCL_HASH_SIZE];
  331.  
  332.  
  333. /* variables for flags:
  334.  * printstats - if true (-v), dump statistics
  335.  * syntaxerror - true if a syntax error has been found
  336.  * eofseen - true if we've seen an eof in the input file
  337.  * ddebug - if true (-d), make a "debug" scanner
  338.  * trace - if true (-T), trace processing
  339.  * spprdflt - if true (-s), suppress the default rule
  340.  * interactive - if true (-I), generate an interactive scanner
  341.  * caseins - if true (-i), generate a case-insensitive scanner
  342.  * useecs - if true (-ce flag), use equivalence classes
  343.  * fulltbl - if true (-cf flag), don't compress the DFA state table
  344.  * usemecs - if true (-cm flag), use meta-equivalence classes
  345.  * fullspd - if true (-F flag), use Jacobson method of table representation
  346.  * gen_line_dirs - if true (i.e., no -L flag), generate #line directives
  347.  * performance_report - if true (i.e., -p flag), generate a report relating
  348.  *   to scanner performance
  349.  * backtrack_report - if true (i.e., -b flag), generate "lex.backtrack" file
  350.  *   listing backtracking states
  351.  * yymore_used - if true, yymore() is used in input rules
  352.  * reject - if true, generate backtracking tables for REJECT macro
  353.  * real_reject - if true, scanner really uses REJECT (as opposed to just
  354.  *               having "reject" set for variable trailing context)
  355.  * continued_action - true if this rule's action is to "fall through" to
  356.  *                    the next rule's action (i.e., the '|' action)
  357.  * yymore_really_used - has a REALLY_xxx value indicating whether a
  358.  *                      %used or %notused was used with yymore()
  359.  * reject_really_used - same for REJECT
  360.  */
  361.  
  362. extern int printstats, syntaxerror, eofseen, ddebug, trace, spprdflt;
  363. extern int interactive, caseins, useecs, fulltbl, usemecs;
  364. extern int fullspd, gen_line_dirs, performance_report, backtrack_report;
  365. extern int yymore_used, reject, real_reject, continued_action;
  366.  
  367. #define REALLY_NOT_DETERMINED 0
  368. #define REALLY_USED 1
  369. #define REALLY_NOT_USED 2
  370. extern int yymore_really_used, reject_really_used;
  371.  
  372.  
  373. /* variables used in the flex input routines:
  374.  * datapos - characters on current output line
  375.  * dataline - number of contiguous lines of data in current data
  376.  *    statement.  Used to generate readable -f output
  377.  * skelfile - the skeleton file
  378.  * yyin - input file
  379.  * temp_action_file - temporary file to hold actions
  380.  * backtrack_file - file to summarize backtracking states to
  381.  * action_file_name - name of the temporary file
  382.  * infilename - name of input file
  383.  * linenum - current input line number
  384.  */
  385.  
  386. extern int datapos, dataline, linenum;
  387. extern FILE *skelfile, *yyin, *temp_action_file, *backtrack_file;
  388. extern char *infilename;
  389. extern char action_file_name[];
  390.  
  391.  
  392. /* variables for stack of states having only one out-transition:
  393.  * onestate - state number
  394.  * onesym - transition symbol
  395.  * onenext - target state
  396.  * onedef - default base entry
  397.  * onesp - stack pointer
  398.  */
  399.  
  400. extern int onestate[ONE_STACK_SIZE], onesym[ONE_STACK_SIZE];
  401. extern int onenext[ONE_STACK_SIZE], onedef[ONE_STACK_SIZE], onesp;
  402.  
  403.  
  404. /* variables for nfa machine data:
  405.  * current_mns - current maximum on number of NFA states
  406.  * num_rules - number of the last accepting state; also is number of
  407.  *             rules created so far
  408.  * current_max_rules - current maximum number of rules
  409.  * lastnfa - last nfa state number created
  410.  * firstst - physically the first state of a fragment
  411.  * lastst - last physical state of fragment
  412.  * finalst - last logical state of fragment
  413.  * transchar - transition character
  414.  * trans1 - transition state
  415.  * trans2 - 2nd transition state for epsilons
  416.  * accptnum - accepting number
  417.  * assoc_rule - rule associated with this NFA state (or 0 if none)
  418.  * state_type - a STATE_xxx type identifying whether the state is part
  419.  *              of a normal rule, the leading state in a trailing context
  420.  *              rule (i.e., the state which marks the transition from
  421.  *              recognizing the text-to-be-matched to the beginning of
  422.  *              the trailing context), or a subsequent state in a trailing
  423.  *              context rule
  424.  * rule_type - a RULE_xxx type identifying whether this a a ho-hum
  425.  *             normal rule or one which has variable head & trailing
  426.  *             context
  427.  * rule_linenum - line number associated with rule
  428.  */
  429.  
  430. extern int current_mns, num_rules, current_max_rules, lastnfa;
  431. extern int *firstst, *lastst, *finalst, *transchar, *trans1, *trans2;
  432. extern int *accptnum, *assoc_rule, *state_type, *rule_type, *rule_linenum;
  433.  
  434. /* different types of states; values are useful as masks, as well, for
  435.  * routines like check_trailing_context()
  436.  */
  437. #define STATE_NORMAL 0x1
  438. #define STATE_TRAILING_CONTEXT 0x2
  439.  
  440. /* global holding current type of state we're making */
  441.  
  442. extern int current_state_type;
  443.  
  444. /* different types of rules */
  445. #define RULE_NORMAL 0
  446. #define RULE_VARIABLE 1
  447.  
  448. /* true if the input rules include a rule with both variable-length head
  449.  * and trailing context, false otherwise
  450.  */
  451. extern int variable_trailing_context_rules;
  452.  
  453.  
  454. /* variables for protos:
  455.  * numtemps - number of templates created
  456.  * numprots - number of protos created
  457.  * protprev - backlink to a more-recently used proto
  458.  * protnext - forward link to a less-recently used proto
  459.  * prottbl - base/def table entry for proto
  460.  * protcomst - common state of proto
  461.  * firstprot - number of the most recently used proto
  462.  * lastprot - number of the least recently used proto
  463.  * protsave contains the entire state array for protos
  464.  */
  465.  
  466. extern int numtemps, numprots, protprev[MSP], protnext[MSP], prottbl[MSP];
  467. extern int protcomst[MSP], firstprot, lastprot, protsave[PROT_SAVE_SIZE];
  468.  
  469.  
  470. /* variables for managing equivalence classes:
  471.  * numecs - number of equivalence classes
  472.  * nextecm - forward link of Equivalence Class members
  473.  * ecgroup - class number or backward link of EC members
  474.  * nummecs - number of meta-equivalence classes (used to compress
  475.  *   templates)
  476.  * tecfwd - forward link of meta-equivalence classes members
  477.  * tecbck - backward link of MEC's
  478.  */
  479.  
  480. extern int numecs, nextecm[CSIZE + 1], ecgroup[CSIZE + 1], nummecs;
  481. extern int tecfwd[CSIZE + 1], tecbck[CSIZE + 1];
  482.  
  483.  
  484. /* variables for start conditions:
  485.  * lastsc - last start condition created
  486.  * current_max_scs - current limit on number of start conditions
  487.  * scset - set of rules active in start condition
  488.  * scbol - set of rules active only at the beginning of line in a s.c.
  489.  * scxclu - true if start condition is exclusive
  490.  * sceof - true if start condition has EOF rule
  491.  * scname - start condition name
  492.  * actvsc - stack of active start conditions for the current rule
  493.  */
  494.  
  495. extern int lastsc, current_max_scs, *scset, *scbol, *scxclu, *sceof, *actvsc;
  496. extern char **scname;
  497.  
  498.  
  499. /* variables for dfa machine data:
  500.  * current_max_dfa_size - current maximum number of NFA states in DFA
  501.  * current_max_xpairs - current maximum number of non-template xtion pairs
  502.  * current_max_template_xpairs - current maximum number of template pairs
  503.  * current_max_dfas - current maximum number DFA states
  504.  * lastdfa - last dfa state number created
  505.  * nxt - state to enter upon reading character
  506.  * chk - check value to see if "nxt" applies
  507.  * tnxt - internal nxt table for templates
  508.  * base - offset into "nxt" for given state
  509.  * def - where to go if "chk" disallows "nxt" entry
  510.  * tblend - last "nxt/chk" table entry being used
  511.  * firstfree - first empty entry in "nxt/chk" table
  512.  * dss - nfa state set for each dfa
  513.  * dfasiz - size of nfa state set for each dfa
  514.  * dfaacc - accepting set for each dfa state (or accepting number, if
  515.  *    -r is not given)
  516.  * accsiz - size of accepting set for each dfa state
  517.  * dhash - dfa state hash value
  518.  * numas - number of DFA accepting states created; note that this
  519.  *    is not necessarily the same value as num_rules, which is the analogous
  520.  *    value for the NFA
  521.  * numsnpairs - number of state/nextstate transition pairs
  522.  * jambase - position in base/def where the default jam table starts
  523.  * jamstate - state number corresponding to "jam" state
  524.  * end_of_buffer_state - end-of-buffer dfa state number
  525.  */
  526.  
  527. extern int current_max_dfa_size, current_max_xpairs;
  528. extern int current_max_template_xpairs, current_max_dfas;
  529. extern int lastdfa, lasttemp, *nxt, *chk, *tnxt;
  530. extern int *base, *def, tblend, firstfree, **dss, *dfasiz;
  531. extern union dfaacc_union
  532.     {
  533.     int *dfaacc_set;
  534.     int dfaacc_state;
  535.     } *dfaacc;
  536. extern int *accsiz, *dhash, numas;
  537. extern int numsnpairs, jambase, jamstate;
  538. extern int end_of_buffer_state;
  539.  
  540. /* variables for ccl information:
  541.  * lastccl - ccl index of the last created ccl
  542.  * current_maxccls - current limit on the maximum number of unique ccl's
  543.  * cclmap - maps a ccl index to its set pointer
  544.  * ccllen - gives the length of a ccl
  545.  * cclng - true for a given ccl if the ccl is negated
  546.  * cclreuse - counts how many times a ccl is re-used
  547.  * current_max_ccl_tbl_size - current limit on number of characters needed
  548.  *    to represent the unique ccl's
  549.  * ccltbl - holds the characters in each ccl - indexed by cclmap
  550.  */
  551.  
  552. extern int lastccl, current_maxccls, *cclmap, *ccllen, *cclng, cclreuse;
  553. extern int current_max_ccl_tbl_size;
  554. extern char *ccltbl;
  555.  
  556.  
  557. /* variables for miscellaneous information:
  558.  * starttime - real-time when we started
  559.  * endtime - real-time when we ended
  560.  * nmstr - last NAME scanned by the scanner
  561.  * sectnum - section number currently being parsed
  562.  * nummt - number of empty nxt/chk table entries
  563.  * hshcol - number of hash collisions detected by snstods
  564.  * dfaeql - number of times a newly created dfa was equal to an old one
  565.  * numeps - number of epsilon NFA states created
  566.  * eps2 - number of epsilon states which have 2 out-transitions
  567.  * num_reallocs - number of times it was necessary to realloc() a group
  568.  *          of arrays
  569.  * tmpuses - number of DFA states that chain to templates
  570.  * totnst - total number of NFA states used to make DFA states
  571.  * peakpairs - peak number of transition pairs we had to store internally
  572.  * numuniq - number of unique transitions
  573.  * numdup - number of duplicate transitions
  574.  * hshsave - number of hash collisions saved by checking number of states
  575.  * num_backtracking - number of DFA states requiring back-tracking
  576.  * bol_needed - whether scanner needs beginning-of-line recognition
  577.  */
  578.  
  579. extern char *starttime, *endtime, nmstr[MAXLINE];
  580. extern int sectnum, nummt, hshcol, dfaeql, numeps, eps2, num_reallocs;
  581. extern int tmpuses, totnst, peakpairs, numuniq, numdup, hshsave;
  582. extern int num_backtracking, bol_needed;
  583.  
  584. char *allocate_array(), *reallocate_array();
  585.  
  586. #define allocate_integer_array(size) \
  587.     (int *) allocate_array( size, sizeof( int ) )
  588.  
  589. #define reallocate_integer_array(array,size) \
  590.     (int *) reallocate_array( (char *) array, size, sizeof( int ) )
  591.  
  592. #define allocate_int_ptr_array(size) \
  593.     (int **) allocate_array( size, sizeof( int * ) )
  594.  
  595. #define allocate_char_ptr_array(size) \
  596.     (char **) allocate_array( size, sizeof( char * ) )
  597.  
  598. #define allocate_dfaacc_union(size) \
  599.     (union dfaacc_union *) \
  600.         allocate_array( size, sizeof( union dfaacc_union ) )
  601.  
  602. #define reallocate_int_ptr_array(array,size) \
  603.     (int **) reallocate_array( (char *) array, size, sizeof( int * ) )
  604.  
  605. #define reallocate_char_ptr_array(array,size) \
  606.     (char **) reallocate_array( (char *) array, size, sizeof( char * ) )
  607.  
  608. #define reallocate_dfaacc_union(array, size) \
  609.     (union dfaacc_union *)  reallocate_array( (char *) array, size, sizeof( union dfaacc_union ) )
  610.  
  611. #define allocate_character_array(size) allocate_array( size, sizeof( char ) )
  612.  
  613. #define reallocate_character_array(array,size) \
  614.     reallocate_array( array, size, sizeof( char ) )
  615.  
  616.  
  617. /* used to communicate between scanner and parser.  The type should really
  618.  * be YYSTYPE, but we can't easily get our hands on it.
  619.  */
  620. extern int yylval;
  621.